﻿using System;
using System.ComponentModel;
using Elentok.Common;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using Elentok.Common.Async;

namespace AMail.Common.Interfaces.Data
{
  /// <summary>
  /// Defines a mail archive
  /// </summary>
  public interface IMailArchive : INotifyPropertyChanged
  {
    /// <summary>
    /// Gets the root folder of the archive
    /// </summary>
    IMailFolder Root { get; }

    /// <summary>
    /// Gets the filename of the archive
    /// </summary>
    string Filename { get; }

    /// <summary>
    /// Gets the password of the archive
    /// </summary>
    string Passphrase { get; }

    /// <summary>
    /// Gets whether there are unsaved changes in the archive
    /// </summary>
    bool HasUnsavedChanges { get; }

    /// <summary>
    /// Returns the source of the given message from the archive
    /// </summary>
    /// <param name="message"></param>
    /// <returns></returns>
    byte[] ExtractMessageSource(IMailMessage message);

    /// <summary>
    /// Changes the password of the archive
    /// </summary>
    /// <param name="newPassphrase"></param>
    /// <param name="progressNotifier"></param>
    void ChangePassword(string newPassphrase, IAsyncProgressNotifier progressNotifier);

    /// <summary>
    /// Saves the pending changes in this archive
    /// </summary>
    /// <param name="progressNotifier"></param>
    /// <exception cref="SaveArchiveException"></exception>
    void Save(IAsyncProgressNotifier progressNotifier);

    /// <summary>
    /// Undoes the last change
    /// </summary>
    void Undo();
  }
}
